/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.govProcure.db.impl;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.govProcure.db.dao.ProcureBudgetEditDao;
import com.yunhoo.govProcure.model.CateDataModel;
import com.yunhoo.govProcure.model.CateEditBase;
import com.yunhoo.govProcure.model.CateEditDetail;
import com.yunhoo.sys.db.util.DbTool;
import com.yunhoo.sys.util.common.LoginParam;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class ProcureBudgetEditDaoImpl extends SqlMapDaoTemplate implements ProcureBudgetEditDao {

    private static SqlMapClient sqlmap;
    private String nameSpace = "procureBudgetEdit.";

    public ProcureBudgetEditDaoImpl(DaoManager daoManager) {
        super(daoManager);
        sqlmap = sqlmap = DbTool.getSqlMapClient();
    }

    @Override
    public List<String> queryAllCategroyStandardCode() {
        System.out.println(nameSpace + "queryAllCategroyStandardCode");
        try {
            String orgCode = LoginParam.getOrg().getCode();
            return sqlmap.queryForList(nameSpace + "queryAllCategroyStandardCode",orgCode);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateDataModel> queryCategroyStandardByCategoryCode(String categoryCode) {
        System.out.println(nameSpace + "queryCategroyStandardByCategoryCode");
        try {
            Map map = new HashMap();
            map.put("orgCode",LoginParam.getOrg().getCode());
            map.put("cateCode",categoryCode);
            return sqlmap.queryForList(nameSpace + "queryCategroyStandardByCategoryCode", map);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public CateEditBase queryCateEditBaseByDeptAndPerson(CateEditBase param) {
        System.out.println(nameSpace + "queryCateEditBaseByDeptAndPerson");
        try {
            return (CateEditBase) sqlmap.queryForObject(nameSpace + "queryCateEditBaseByDeptAndPerson", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateEditDetail> queryListCateEditDetailByNumber(CateEditDetail param) {
        System.out.println(nameSpace + "queryListCateEditDetailByNumber");
        try {
            return sqlmap.queryForList(nameSpace + "queryListCateEditDetailByNumber", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateEditDetail> queryListCateEditDetailForCheck(CateEditDetail param) {
        System.out.println(nameSpace + "queryListCateEditDetailForCheck");
        try {
            return sqlmap.queryForList(nameSpace + "queryListCateEditDetailForCheck", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public Integer queryMaxNumberFromBase() {
        System.out.println(nameSpace + "queryMaxNumberFromBase");
        try {
            String orgCode = LoginParam.getOrg().getCode();
            return (Integer) sqlmap.queryForObject(nameSpace + "queryMaxNumberFromBase",orgCode);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public Integer queryMaxNumberFromDetail() {
        System.out.println(nameSpace + "queryMaxNumberFromDetail");
        try {
            return (Integer) sqlmap.queryForObject(nameSpace + "queryMaxNumberFromDetail");
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public void insertCateEditBase(CateEditBase param) throws SQLException {
        sqlmap.insert(nameSpace + "insertCateEditBase", param);
    }

    @Override
    public void insertCateEditDetail(CateEditDetail param) throws SQLException {
        sqlmap.insert(nameSpace + "insertCateEditDetail", param);
    }

    @Override
    public void updateCateEditDetailById(CateEditDetail param) throws SQLException {
        sqlmap.update(nameSpace + "updateCateEditDetailById", param);
    }

    @Override
    public void deleteCateEditDetailById(CateEditDetail param) throws SQLException {
        sqlmap.delete(nameSpace + "deleteCateEditDetailById", param);
    }
}
